package cn.swust.designpatternlearningplatform.dao.sql;

import org.apache.ibatis.jdbc.SQL;

public class TestPaperContentDaoSql {
    public String deleteTestPaperContent(String testId) {
    return new SQL(){
        {
            DELETE_FROM("test_paper_concete_content");
            WHERE("paper_number=#{testId}");
        }
    }.toString();
    }
    /**
     * @param topicId:
    	 * @param paperNumber:
    	 * @param score:
      * @return String
     * @author wang
     * description 试卷关联题目的表做添加信息
     * date 2023/5/28 13:17
     */
    public  String addTestPaper(Integer topicId, String paperNumber, String score){
        return new SQL(){
            {
                INSERT_INTO("test_paper_concete_content");
                VALUES("paper_number","#{paperNumber}");
                VALUES("topic_id","#{topicId}");
                VALUES("score","#{score}");
            }
        }.toString();
    }
    /**
     * @param testId:
      * @return String
     * @author wang
     * description 通过试卷的id查找相应的topicId
     * date 2023/5/28 15:27
     */
    public String selecteTestPaper(String testId){
        return new SQL(){
            {
                SELECT("topic_id");
                FROM("test_paper_concete_content");
                WHERE("paper_number=#{testId}");
            }
        }.toString();

    }
    public String updateTestPaperTopic(String paperNumber, Integer topicId,Integer newTopicId){
        return new SQL(){
            {
                UPDATE("test_paper_concete_content");
                SET("topic_id=#{newTopicId}");
                WHERE("paper_number=#{paperNumber}","topic_id=#{topicId}");
            }
        }.toString();
    }
}
